package com.cc.controller;



import com.cc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/UserR")
@ResponseBody
public class UserResponseController {

    @GetMapping("/findUser")

    public User findUser(Integer userId){
        System.out.println("前台传入的userId: "+userId);
        //调用服务接口
        //返回数据
        User user = new User();
        user.setId(1);
        user.setAge(18);
        user.setName("娃哈哈");
        user.setSalary(5000);

        return user;

    }
    @GetMapping("/findList")
    @ResponseBody
public List<User> findList(){
        List<User> users = new ArrayList<>();
    User user = new User();
    user.setId(1);
    user.setAge(18);
    user.setName("娃哈哈");
    user.setSalary(5000);
    users.add(user);

    User user1 = new User();
    user.setId(1);
    user.setAge(18);
    user.setName("娃哈哈");
    user.setSalary(5000);
    users.add(user1);

    User user2 = new User();
    user.setId(1);
    user.setAge(18);
    user.setName("娃哈哈");
    user.setSalary(5000);
    users.add(user2);
    return users;
    }
}
